package com.tj.bo.trade.server.dao;

import com.fqgj.common.api.Page;
import com.fqgj.common.base.BaseMapper;
import com.tj.bo.trade.server.entity.BinaryTradeEntity;
import com.tj.bo.trade.server.entity.bussiness.TradeDailyAvgEntity;
import com.tj.bo.trade.server.entity.bussiness.TradeDailyWinRateEntity;
import com.tj.bo.trade.server.entity.bussiness.TradeDispersionEntity;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * User: binary
 * Date: 2020-06-05
 * Time: 11:03:09.747
 */

public interface BinaryTradeDao extends BaseMapper<BinaryTradeEntity> {

    BinaryTradeEntity selectBinaryTradeByTradeNo(String tradeNo);

    List<BinaryTradeEntity> selectBinaryTradeListByPageCondition(Page page, Integer tradeType, String userCode);

    List<BinaryTradeEntity> selectsBinaryTradeListByCondition(Integer orderStatus);

    List<BinaryTradeEntity> selectsBinaryTradeListByStatusAndTime(Integer orderStatus, Integer tradeType, Date endTime);

    List<BinaryTradeEntity> selectsBinaryTradeListByTime(String userCode, String productCode, Integer orderStatus, Integer tradeType, Date startDate, Date endDate);

    Integer countBinaryTrade(String userCode, Integer orderStatus, Integer tradeType);

    Integer countBinaryTradeByTime(String productCode, Date queryTime);



    List<BinaryTradeEntity> selectBinaryTradeListByUserCodeAndProductCode(String userCode, Integer tradeType, Integer orderStatus, String productCode);

    /**
     * 计算大盘总收益
     * @param createDate
     * @return
     */
    BigDecimal calculateTotalProfitAmount(Date createDate);

    /**
     * 计算用户总收益
     * @param createDate
     * @param userCode
     * @return
     */
    BigDecimal calculateUserTotalProfitAmount(Date createDate, String userCode);

    boolean isProductNewUser(String userCode, String productCode);

    /**
     * 查询用户日均、件均
     *
     * @param userCode
     * @param productCode
     * @return
     */
    TradeDailyAvgEntity selectTradeDailyAvg(String userCode, String productCode);

    /**
     * 查询用户离散系数
     *
     * @param userCode
     * @param productCode
     * @return
     */
    TradeDispersionEntity selectTradeDispersion(String userCode, String productCode);

    /**
     * 查询每日胜率
     *
     * @param userCode
     * @param productCode
     * @return
     */
    List<TradeDailyWinRateEntity> selectDailyWinRate(String userCode, String productCode);

}